package com.easy.frame.common.generate.builder;

import java.lang.reflect.Field;

/**
 * 根据entity生成ResultMap
 */
public class ResultMapGenerator {
    public static void main(String[] args) {
        String className = Object.class.getName();


        String resultMapName = "BaseResultMap";
        String firstRow = "<resultMap id=\"" + resultMapName + "\" type=\"" + className + "\">";
        System.out.println(firstRow);
        Field[] filedList = Object.class.getDeclaredFields();
        for (int i = 0; i < filedList.length; i++) {
            String fieldName = filedList[i].getName();
            String row = "";
            if ("id".equals(fieldName)) {
                row = "    <id column=\"" + fieldName + "\" property=\"" + fieldName + "\"/>";
            } else {
                row = "    <result column=\"" + fieldName + "\" property=\"" + fieldName + "\"/>";
            }
            System.out.println(row);
        }
        String lastRow = "</resultMap>";

        System.out.println(lastRow);
    }

    public static void getSqlFieldName(String fieldName) {

    }
}
